<template>
    <div ref="body">
        <Form :label-width="120" inline>
            <Form-item label="预警姓名:">
                <Input v-model="queryParam.yjab0001" placeholder="请输入姓名" style="width:200px"/>
            </Form-item>

            <Form-item label="预警证件号码:">
                <Input v-model="queryParam.yjab0002" placeholder="请输入身份证号码" style="width:200px"/>
            </Form-item>

            <Form-item label="预警类别:">
                <c-dict-select v-model="queryParam.yjab0004" dictCode="warningcategory" show-keys="400,500,700,2000,2500,2800,2900,3100,3200,3250,3300,3400,3500,3600,3700,3900"/>
            </Form-item>

            <Form-item label="属地区划:">
                <area-linkage :areaCode.sync="queryParam.yjab0014"></area-linkage>
            </Form-item>

            <Form-item label="预警时间:">
                <DatePicker type="daterange" split-panels v-model="queryParam.yjab0005"
                            placeholder="请选择预警时间" style="width: 200px"  :editable="false"></DatePicker>
            </Form-item>

            <Form-item label="处置状态:">
                <c-dict-select v-model="queryParam.yjab0006" placeholder="请选择处置状态"
                               dictCode="warning_handle_state"/>
            </Form-item>

            <Form-item label="救助类型:">
                <c-dict-select v-model="queryParam.yjab0013" dictCode="systemsubtype"
                               showKeys="1010,1020,1030,1040,1050,1060,1070,1080,1090"/>
            </Form-item>

            <Form-item label="处置方案:">
                <c-dict-select v-model="queryParam.yjab0012" placeholder="请选择处置方案"
                               dictCode="warning_handle_type"/>
            </Form-item>

            <Row class="button_row">
                <span style="float: right;">
                 <Button type="primary" @click="searchQueryNew">查询</Button>
                 <Button type="primary" class="button_item_left" @click="searchResetNew">重置</Button>
                     </span>
            </Row>
        </Form>

        <div class="table_div">
            <vxe-table border
                       auto-resize
                       row-id="id"
                       :row-key="true"
                       show-overflow="tooltip"
                       highlight-hover-row
                       align="center"
                       header-align="center"
                       ref="xTree"
                       :loading="Loading"
                       :data="tableData">
                <vxe-table-column field="yjab0001" title="预警姓名" align="center" width="100" fixed="left"/>
                <vxe-table-column field="yjab0002" title="预警证件号码" align="center" width="180" fixed="left"/>
                <vxe-table-column field="yjab0004_name" title="预警类别" align="center" width="150"/>
                <vxe-table-column field="yjab0013_name" title="救助类型" align="center" width="180"/>
                <vxe-table-column field="yjab0014" title="属地区划" align="center" width="220" :formatter="renderAreaName"/>
                <vxe-table-column field="yjab0005" title="预警时间" align="center" width="120" :formatter="renderTime"/>
                <vxe-table-column field="yjab0006_name" title="处置状态" align="center" width="120"/>
                <vxe-table-column field="yjab0007" title="处置人" align="center" width="120"/>
                <vxe-table-column field="yjab0008" title="处置时间" align="center" width="120" :formatter="renderTime"/>
                <vxe-table-column field="yjab0012_name" title="处置方案" align="center" width="120"/>
                <vxe-table-column title="处置操作" align="center" width="390" fixed="right" field="do" :visible="true">
                    <template #default="{row}">
                        <Button type="success" @click="handleSolved(row,'01')"
                                v-show="row.yjab0012 == null " :loading="btnLoading" :disabled="row.auth=='no'">已完成处置
                        </Button>
                        <Button type="info" @click="handleSolved(row,'02')" style="margin-left: 10px"
                                v-show="row.yjab0012 == null" :loading="btnLoading" :disabled="row.auth=='no'">维持现状
                        </Button>
                        <Button type="warning" @click="handleSolved(row,'03')" style="margin-left: 10px"
                                v-show="row.yjab0012 == null" :loading="btnLoading" :disabled="row.auth=='no'">动态变更
                        </Button>
                        <Button type="error" @click="handleSolved(row,'04')" style="margin-left: 10px"
                                v-show="row.yjab0012 == null" :loading="btnLoading" :disabled="row.auth=='no'">停保
                        </Button>
                    </template>
                </vxe-table-column>
            </vxe-table>
            <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
                  @on-change="handleTableChange" :current="pageNo"></Page>
        </div>
        <application-modal ref="modal" @ok="modalFormOk"/>
    </div>
</template>
<script>
  import { CommonMixin } from '@/views/common/js/CommonMixin'
  import { postAction } from '@/api/request'
  import applicationModal from './modules/applicationModal'

  export default {
    name: 'ss02017List',
    mixins: [CommonMixin],
    components: { applicationModal },
    data () {
      return {
        url: {
          list: '/api/ac/subsistence/ss02017Service/page',
          handle: '/api/ac/subsistence/ss02017Service/updateHandleWarnSolve',
        },
        Loading: true,
        btnLoading:false,
        queryParam: {
          yjab0006:'0'
        },

      }
    },
    methods: {
      searchResetNew () {
        this.queryParam={};
        this.loadData(1)
      },
      searchQueryNew () {
        var time = this.queryParam.yjab0005
        if (time) {
          if (time[0]) {
            this.queryParam.yjab0005_begin = this.DateFormat(time[0], 'YYYY-MM-DD') + ' 00:00:00'
          }
          if (time[1]) {
            this.queryParam.yjab0005_end = this.DateFormat(time[1], 'YYYY-MM-DD') + ' 23:59:59'
          }
        }
        if (this.queryParam.yjab0006 == '200') {
          this.$refs.xTree.getColumnByField('do').visible = false
        } else {
          this.$refs.xTree.getColumnByField('do').visible = true
        }
        this.$refs.xTree.refreshColumn()
        this.loadData(1)
      },
      handleSolved: function (obj, type) {
        //this.btnLoading=true;
        if(obj.msg){
          this.$Modal.confirm({
            title: obj.msg,
            onOk: () => {
              this.showModel(obj,type);
            },
            onCancel: () => {
              //this.btnLoading=false;
            },
          })
        }else{
          this.showModel(obj,type);
        }
      },
      showModel:function (obj,type) {
        let that = this
        obj.yjab0012 = type
        postAction(that.url.handle, obj).then((res) => {
          if (res.data.errcode == 9999) {
            that.$Message.error(res.data.errmsg)
          } else {
            console.log(res.data);
            obj.ss12001Id=res.data.data.ss12001Id;
            obj.ssca0002=res.data.data.ssca0002;
            obj.ssca0016=res.data.data.ssca0016;
            obj.ssca0001=res.data.data.ss16001Id;
            obj.ssca0012=res.data.data.ssca0012;
            obj.azcp0001=obj.yjab0002;

            var width = this.$refs.body.clientWidth;
            this.$refs.modal.edit(obj);
            this.$refs.modal.width = width + 40;
            this.$refs.modal.key = this.uuid();
          }
        }).finally(()=>{
          //this.btnLoading=false;
        })
      }
    },
    created () {
      this.findAreaList()
      this.queryParam.yjab0006='0';
    },
  }
</script>

<style scoped>

</style>
